# PZEMTOOL

The tool for `PZEM-004` devices maitainance.

## Features

The `pzemtool` is intended to:

  * Read current device address.
  * Change device address.
  * Read and display values.
  * Energy reset.

## Usage

```
Usage: ./pzemtool [options]

 -t[addr]               specify target addr
 -p[port]               tty port (default /dev/ttyUSB0)
 -s[num]                change device address.
 -r[time]               read values from device
 -e                     reset energy

pzemtool v0.1.1 by @hakanai
```


## Example

To read device address (`pzemtool -a`)

```
sent: f8 03 00 02 00 01 31 a3
recv: f8 03 02 00 10 25 9c 00
Device address: 0x10
```

To change device addres (`pzemtool -s 55`)

```
Change device address to 0x37
sent: f8 03 00 02 00 01 31 a3
recv: f8 03 02 00 10 25 9c 00
Device address: 0x10
Trying to change...
sent: 10 06 00 02 00 37 6a 9d
recv: 10 06 00 02 00 37 6a 9d
Success.
sent: f8 03 00 02 00 01 31 a3
recv: f8 03 02 00 37 65 86 00
Current device address is: 0x37
```

Example of values reading (`pzemtool -r2`)

```
ent: f8 03 00 02 00 01 31 a3
recv: f8 03 02 00 37 65 86 00
Device address: 0x37
sent: 37 04 00 00 00 0a 75 9b
recv: 37 04 14 09 0d 00 31 00 00 00 2b 00 00 00 15 00 00 01 f4 00 26 00 00 18 00

Voltage:        231.699997V
Current:        0.049000A
Frequency:      50.000000Hz
Power:          4.300000W
Energy:         0.021000Wh
pf:             0.380000
alarms:         0
```

Energy reset example (`pzemtool -t 5 -e`)

```
Using device: 0x05
recv: 05 42 82 d1 00
Energy reset successful
```

